package cloud.ben.smallscalepigfarmmanagementsystem.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * @Author: Ben
 * @Date: 2022/3/1 17:40
 */
@Data
@ToString
@TableName("user")
@NoArgsConstructor
@ApiModel(description = "用户基本信息表")
public class User {

    /**
     * 表id
     */
    @TableId(type = IdType.AUTO)
    @ApiModelProperty(required = true,value = "用户id")
    private Integer id;

    /**
     * 用户名
     */
    @NotNull(message = "用户名为空")
    @Pattern(regexp = "^[\\w\\u4e00-\\u9fa5]{1,6}$",message = "请输入1-6位的英文、数字、中文、下划线")
    @ApiModelProperty(required = true,value = "用户名")
    private String userName;

    /**
     * 密码
     */
    @NotNull(message = "密码为空")
    @Pattern(regexp = "^[\\w]{6,12}$",message = "请输入6-12位的英文、数字、下划线")
    @ApiModelProperty(required = true,value = "用户密码")
    private String password;

    /**
     * 手机号
     */
    @NotNull(message = "手机号为空")
    @ApiModelProperty(required = true,value = "手机号")
    private String phoneNumber;

    /**
     * 邮箱
     */
    @NotNull(message = "邮箱为空")
    @Pattern(regexp = "^([a-zA-Z]|[0-9])(\\w|\\-)+@[a-zA-Z0-9]+\\.([a-zA-Z]{2,4})$",message = "邮箱输入有误")
    @ApiModelProperty(required = true,value = "邮箱")
    private String email;

    /**
     * 密保问题
     */
    @NotNull(message = "密保问题为空")
    @ApiModelProperty(required = true,value = "密保问题")
    private String  encryptedProblem;

    /**
     * 密保答案
     */
    @NotNull(message = "密保答案为空")
    @ApiModelProperty(required = true,value = "密保答案")
    private String  encryptedAnswer;

    /**
     * 用户权限
     */
    @ApiModelProperty(required = true,value = "用户权限")
    private String roles;

    /**
     * 记住我
     */
//    private Integer  rememberMe;


    public User(Integer id, String userName, String password, String phoneNumber, String email, String encryptedProblem, String encryptedAnswer, String roles) {
        this.id = id;
        this.userName = userName;
        this.password = password;
        this.phoneNumber = phoneNumber;
        this.email = email;
        this.encryptedProblem = encryptedProblem;
        this.encryptedAnswer = encryptedAnswer;
        this.roles = roles;
    }


    public User(String userName, String password) {
        this.userName = userName;
        this.password = password;
    }
}
